#include <stdio.h>
#include <vector>
#include "mpmm_type_define.h"

//sendMPMMdata
//write_mpmm_mem
//
MpmmData get_mpmm_data();

int main(){
	/**/
	MpmmData mpmm_data; 
	mpmm_data = get_mpmm_data();
	bool mark_lock[8];
	bool mark_abort[8];
	bool mark_commit[8];
	int core_id = mpmm_data.core_id;
	bool lock = mpmm_data.Lock;
	bool commit = mpmm_data.Commit;
	bool abort = mpmm_data.Abort;
	int thread = mpmm_data.Thread;
	int cpus = core_id*2+thread;
	mpmm_data.cpus = cpus;

	vector<long>mpmm_index0;
	vector<long>mpmm_index1;
	vector<long>mpmm_index2;
	vector<long>mpmm_index3;
	vector<long>mpmm_index4;
	vector<long>mpmm_index5;
	vector<long>mpmm_index6;
	vector<long>mpmm_index7;

	vector<MpmmData> mpmm_data_array;
	long index = 0;
	if (commit){
		mark_lock[cpus] = false;
		if !(mark_lock[0] || mark_lock[1] || mark_lock[2] || mark_lock[3] ||\
		     mark_lock[4] || mark_lock[5] || mark_lock[6] || mark_lock[7] ) {
			//SendAllInQueue;
			index = 0;
		}
		else {
			//MarkCommit to the mapped cpus
		}
	}
	if (abort) {
		mark_lock[cpus] = false;
		//Remove all the cpus data from Lock
		//or MarkAbort to the mapped cpus
		if !(mark_lock[0] || mark_lock[1] || mark_lock[2] || mark_lock[3] ||\
		     mark_lock[4] || mark_lock[5] || mark_lock[6] || mark_lock[7] ) {
			//SendAllInQueue;
			index = 0;
		}
	}
	if (lock) {
		mark_lock[cpus] = true;
		mpmm_data_array.push_back(mpmm_data);
		switch(cpus){
			case 0: mpmm_index0.push_back(index); index=index+1; break;
			case 1: mpmm_index1.push_back(index); index=index+1; break;
			case 2: mpmm_index2.push_back(index); index=index+1; break;
			case 3: mpmm_index3.push_back(index); index=index+1; break;
			case 4: mpmm_index4.push_back(index); index=index+1; break;
			case 5: mpmm_index5.push_back(index); index=index+1; break;
			case 6: mpmm_index6.push_back(index); index=index+1; break;
			case 7: mpmm_index7.push_back(index); index=index+1; break;
		}
	}
	return 0;
}
